
public class Connection {

  private int value;
  private Node fromNode;
  private Node toNode;

  public Connection() {
  }

  public Connection(Node from, Node to, int val) {
    this.fromNode = from;
    this.toNode = to;
    this.value = val;
  }

  public void setFrom(Node from) {
    fromNode = from;
  }

  public void setTo(Node to) {
    toNode = to;
  }

  public void setValue(int val) {
    value = val;
  }

  public void printConnection() {
    System.out.println("Joining " + fromNode.getWord().substring(0, fromNode.getWord().length() - value)
            + " " + toNode.getWord().substring(0, value).toUpperCase()
            + " " + toNode.getWord().substring(value)
            + ", overlap = " + value
            + ", " + fromNode.getWord() + " (conflicts/fitness : " + fromNode.getConflicts() + "), "
            + toNode.getWord() + " (conflicts/fitness: " + toNode.getConflicts() + ")");
    System.out.println("\nOverall score so far = " + Wordsnake.VALUE);
  }

  public Node getFromNode() {
    return fromNode;
  }

  public Node getToNode() {
    return toNode;

  }

  public int getValue() {
    return value;
  }

  public int getConflicts() {
    return this.fromNode.getConflicts() + this.toNode.getConflicts();
  }

  public int getLength() {
    return this.fromNode.getWord().length() + this.toNode.getWord().length() - this.value;
  }

  public int getFitness() {
    return this.fromNode.getFitness() + this.toNode.getFitness();
  }
}